<?php
/**
 * Description of Doctrine
 *
 * @author Lukas Normantas
 */
class Areal_Paginator_Adapter_Doctrine implements Zend_Paginator_Adapter_Interface
{
    /**
     * Array
     *
     * @var Doctrine_Pager
     */
    protected $_pager = null;

    /**
     * Item list
     *
     * @var mixed 
     */
    protected $_items;

    /**
     * Constructor.
     *
     * @param Doctrine_Pager $pager
     * @param array $params
     * @param integer $hydrationMode
     */
    public function __construct(Doctrine_Pager $pager, $params, $hydrationMode)
    {    
        $this->_pager = $pager;
        $this->_items = $this->_pager->execute($params, $hydrationMode);
    }

    /**
     * @param  integer $offset Page offset
     * @param  integer $itemCountPerPage Number of items per page
     * @return array
     */
    public function getItems($offset, $itemCountPerPage)
    {
        return $this->_items;
    }    
    
    /**
     * Returns the total number of rows in the array.
     *
     * @return integer
     */
    public function count()
    {
        return $this->_pager->getNumResults();
    }
}
